export const crudOptions = (vm) => {
  return {
    rowHandle: {
      width: 50,
      view: {
        show () {
          // return !vm.hasPermissions('Retrieve')
          return false
        }
      },
      edit: {
        show () {
          // return !vm.hasPermissions('Update')
          return false
        }
      },
      remove: {
        thin: true,
        text: '',
        show () {
          // return !vm.hasPermissions('Delete')
          return true
        }
      },
      fixed: 'right'
    },
    options: {
      tableType: 'vxe-table',
      rowKey: true, // 必须设置，true or false
      rowId: 'id',
      height: '100%', // 表格高度100%, 使用toolbar必须设置
      highlightCurrentRow: false
    },
    formOptions: { // 表单宽度
      defaultSpan: 24, // 默认的表单 span
      width: '35%'
    },
    indexRow: { // 序号
      title: '序号',
      align: 'center',
      width: 60
    },
    selectionRow: { // 多选框
      align: 'center',
      width: 46
    },
    columns: [
      {
        title: 'Id',
        key: 'id',
        form: { // 表单配置
          disabled: true // 禁用表单编辑
        },
        // type: 'select',
        // dict: { url: ''}, //数据字典
        // search: { disabled: false }, // 开启查询
        disabled: true, // 隐藏列
        sortable: true
      },
      {
        title: '时间',
        key: 'took_time',
        // type: 'select',
        // dict: { url: ''}, //数据字典
        // search: { disabled: false }, // 开启查询
        // disabled: true, // 隐藏列
        form: { // 表单配置
          disabled: false, // 禁用表单编辑
          rules: [{ required: true, message: '时间' }],
          component: {
            props: {
              clearable: true
            },
            placeholder: '请输入时间'
          },
          itemProps: {
            class: { yxtInput: true }
          }
        },
        sortable: true
      },
      {
        title: '返回结果',
        key: 'result',
        // type: 'select',
        // dict: { url: ''}, //数据字典
        // search: { disabled: false }, // 开启查询
        // disabled: true, // 隐藏列
        showOverflow: true,
        form: { // 表单配置
          disabled: false, // 禁用表单编辑
          rules: [{ required: true, message: '返回结果' }],
          component: {
            props: {
              clearable: true
            },
            placeholder: '请输入返回结果'
          },
          itemProps: {
            class: { yxtInput: true }
          }
        },
        sortable: true
      },
      {
        title: '校验结果',
        key: 'verification',
        // type: 'select',
        // dict: { url: ''}, //数据字典
        // search: { disabled: false }, // 开启查询
        // disabled: true, // 隐藏列
        form: { // 表单配置
          disabled: false, // 禁用表单编辑
          rules: [{ required: true, message: '校验结果' }],
          component: {
            props: {
              clearable: true
            },
            placeholder: '请输入校验结果'
          },
          itemProps: {
            class: { yxtInput: true }
          }
        },
        sortable: true
      },
      {
        title: '所属接口',
        key: 'api_belong',
        type: 'select',
        dict: {
          url: '/api/testinfo/',
          label: 'name',
          value: 'id'
        },
        // search: { disabled: false }, // 开启查询
        // disabled: true, // 隐藏列
        form: { // 表单配置
          disabled: false, // 禁用表单编辑
          rules: [{ required: true, message: '所属接口' }],
          component: {
            props: {
              clearable: true
            },
            placeholder: '请输入所属接口'
          },
          itemProps: {
            class: { yxtInput: true }
          }
        },
        sortable: true
      },
      {
        title: '所属环境',
        key: 'env_belong',
        type: 'select',
        dict: {
          url: '/api/envInfo/',
          label: 'env_name',
          value: 'id'
        },
        search: { disabled: false }, // 开启查询
        // disabled: true, // 隐藏列
        form: { // 表单配置
          disabled: false, // 禁用表单编辑
          rules: [{ required: true, message: '所属环境' }],
          component: {
            props: {
              clearable: true
            },
            placeholder: '请输入所属环境'
          },
          itemProps: {
            class: { yxtInput: true }
          }
        },
        sortable: true
      },
      {
        title: '所属项目',
        key: 'project_belong',
        type: 'select',
        dict: {
          url: '/api/projectInfo/',
          label: 'project_name',
          value: 'id'
        },
        // search: { disabled: false }, // 开启查询
        // disabled: true, // 隐藏列
        form: { // 表单配置
          disabled: false, // 禁用表单编辑
          rules: [{ required: true, message: '所属项目' }],
          component: {
            props: {
              clearable: true
            },
            placeholder: '请输入所属项目'
          },
          itemProps: {
            class: { yxtInput: true }
          }
        },
        sortable: true
      },
      {
        title: '所属模块',
        key: 'module_belong',
        type: 'select',
        dict: {
          url: '/api/moduleInfo/',
          label: 'module_name',
          value: 'id'
        },
        // dict: { url: ''}, //数据字典
        // search: { disabled: false }, // 开启查询
        // disabled: true, // 隐藏列
        form: { // 表单配置
          disabled: false, // 禁用表单编辑
          rules: [{ required: true, message: '所属模块' }],
          component: {
            props: {
              clearable: true
            },
            placeholder: '请输入所属模块'
          },
          itemProps: {
            class: { yxtInput: true }
          }
        },
        sortable: true
      }

    ].concat(vm.commonEndColumns(
      {
        update_datetime: { showTable: false }
      }
    ))
  }
}
